import { stringify } from 'qs';
import request from '@/utils/request';
import {formDataCode} from '@/utils/utils';

//获取出售商品列表
export async function GetSellProductList(params) {
    return request(`/${window.storeId}/Product/SearchSellProductListWithPage`, {
        method: 'POST',
        body: {
            ...params
        },
    });
}

//获取已售罄列表
export async function GetSearchSoldOutProductListWithPage(params) {
    return request(`/${window.storeId}/Product/SearchSoldOutProductListWithPage`, {
        method: 'POST',
        body: {
            ...params
        },
    });
}


//获取仓库中列表
export async function GetSearchWarehouseProductListWithPage(params) {
    return request(`/${window.storeId}/Product/SearchWarehouseProductListWithPage`, {
        method: 'POST',
        body: {
            ...params
        },
    });
}

// 获取单个商品规格
export async function GetProductSkuInfoByProductId(params) {
    return request(`/${window.storeId}/Product/GetProductSkuInfoByProductId?${stringify(params)}`);
}

//判断是否
export async function IsMultiProduct(params) {
    return request(`/${window.storeId}/Product/IsMultiProduct?${stringify(params)}`);
}


//获取分类全部分组和未分组
export async function GetProductGroupList(params) {
    return request(`/${window.storeId}/Product/GetProductGroupList?${stringify(params)}`);
}

// 获取标签列表不分页的
export async function GetTagList(params) {
    return request(`/${window.storeId}/Product/GetTagList?${stringify(params)}`);
}

// 修改标签
export async function UpdateProductsTags(params) {
    return request(`/${window.storeId}/Product/UpdateProductsTags`, {
        method: 'POST',
        body: {
            ...params
        }
    });
}

// 修改分类
export async function UpdateProductsGroup(params) {
    return request(`/${window.storeId}/Product/UpdateProductsGroup`, {
        method: 'POST',
        body: {
            ...params
        }
    });
}


// 修改排序
export async function UpdateProductSort(params) {
    return request(`/${window.storeId}/Product/UpdateProductSort`, {
        method: 'POST',
        body: {
            ...params
        }
    });
}

// 修改库存
export async function UpdateProductStock(params) {
    return request(`/${window.storeId}/Product/UpdateProductStock`, {
        method: 'POST',
        body: params
    });
}

// 修改价格
export async function UpdateSProductPrice(params) {
    return request(`/${window.storeId}/Product/UpdateSProductPrice`, {
        method: 'POST',
        body: params
    });
}

// 复制商品
export async function CopyProduct(params) {
    return request(`/${window.storeId}/Product/CopyProduct`, {
        method: 'POST',
        headers:{
            'Content-Type':"application/x-www-form-urlencoded",        
         },
         body: formDataCode(params)
    });
}

// 下架 直接参数
export async function SetProductsOffline(params) {
    return request(`/${window.storeId}/Product/SetProductsOffline`, {
        method: 'POST',
        body: `"${params}"`.toString()
    })
}

// 上架
export async function SetProductsOnline(params) {
    return request(`/${window.storeId}/Product/SetProductsOnline`, {
        method: 'POST',
        body: `"${params}"`.toString()
    })
}

// 删除
export async function DeletesProduct(params) {
    return request(`/${window.storeId}/Product/DeletesProduct`, {
        method: 'POST',
        body: `"${params}"`.toString()
    })
}

//获取多规格会员价信息
export async function GetMemberPriceByProductId(params) {
    return request(`/${window.storeId}/Product/GetMemberPriceByProductId?${stringify(params)}`);
}

//设置商品会员价
export async function UpdateMProductPrice(params) {
    return request(`/${window.storeId}/Product/UpdateMProductPrice`, {
        method: 'POST',
         body: params
    });
}